rm(list=ls())

##############################################################################
# TABLE 1 SCRIPT
##############################################################################

# load packages
#library(texreg)

# load data 
load("data/candidate_GCI.RData")

##############
# RUN MODELS #
##############

LM1 <- lm(votes ~ ranking + factor(region), data = candidate_GCI)
#summary(LM1)
LM2 <- lm(votes ~ ranking + factor(region) + factor(elect_year), data = candidate_GCI)
#summary(LM2)
LM3 <- lm(votes ~ ranking + factor(region) + log_gdp_percap + 
            log_pop + idealpoint_US + idealpoint_RU + nato_bin + 
            eu_bin + g77_bin + oic_bin, data = candidate_GCI)
#summary(LM3)

################
# CREATE TABLE #
################

tab1 <- screenreg(list(LM1,LM3), custom.coef.map = list("votes" = "votes", 
 "ranking" = "ranking"),
 omit.coef = c("region", "elect_year", "Constant", "log_gdp_percap", "log_pop", "idealpoint_US", 
               "idealpoint_RU", "nato_bin","eu_bin", "g77_bin", "oic_bin"), 
 custom.gof.rows = list("Region FE" = c("YES", "YES"), 
                        "Controls" = c("NO","YES")), digits = 3, 
 stars = c(0.001, 0.01, 0.05, 0.1))

print(tab1)

# script complete message 
print("tab1 complete")
